package bookstudytest.threadtest.lock;

/**
 * 不可重入锁，当前线程获得锁之后，未释放锁之前，再次去获取锁的话会获取不到
 */
public class Count {
    Lock lock = new Lock();
    public void doSome() throws InterruptedException {
        lock.getLock();
        System.out.println("获得锁");
//        lock.unlock();
        doOther();
        System.out.println("准备释放锁");
        lock.unlock();

    }

    public void doOther() throws InterruptedException {
        System.out.println("再次获得锁");
        lock.getLock();
        System.out.println("我在获取锁之后，大哥你们好");
        lock.unlock();
    }

    public static void main(String[] args) {

        try {
            new Count().doSome();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
